package com.zzyl.controller.web;

import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.entity.Floor;
import com.zzyl.service.FloorService;
import com.zzyl.vo.FloorVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//楼层管理
@RestController
public class FloorController extends BaseController {

    @Autowired
    private FloorService floorService;

    //=============================监控阶段使用===============================//
    @GetMapping("/floor/getAllWithRoomAndBed")
    @ApiOperation(value = "获取所有楼层 （包含房间和床位）", notes = "无需参数，获取所有楼层，返回楼层信息列表")
    public ResponseResult getAllWithRoomAndBed() {
        List<FloorVo> list = floorService.getAllWithRoomAndBed();
        return success(list);
    }

    //获取全部楼层
    @GetMapping("/floor/getAll")
    public ResponseResult getAll() {
        List<Floor> list = floorService.list();
        return success(list);
    }

    //添加楼层
    @PostMapping("/floor/add")
    public ResponseResult save(@RequestBody Floor floor){
        floorService.save(floor);
        return success();
    }

    //根据id查询楼层
    @GetMapping("/floor/get/{id}")
    public ResponseResult findById(@PathVariable Long id){
        Floor floor = floorService.getById(id);
        return success(floor);
    }

    //修改楼层
    @PutMapping("floor/update")
    public ResponseResult update(@RequestBody Floor floor){
        floorService.updateById(floor);
        return success();
    }

    //删除楼层
    @DeleteMapping("/floor/delete/{id}")
    public ResponseResult delete(@PathVariable Long id){
        floorService.removeById(id);
        return success();
    }

}